package com.sos.widget.binding;

import androidx.annotation.ColorInt;
import androidx.databinding.BindingAdapter;

import com.sos.widget.view.flyco.tablayout.CommonTabLayout;
import com.sos.widget.view.flyco.tablayout.SegmentTabLayout;
import com.sos.widget.view.flyco.tablayout.SlidingTabLayout;

/**
 * @Description
 * @Author 梁浩文
 * @Date 2023/7/21 11:17
 */
public class TabBindingAdapter {
    @BindingAdapter(value = {"saas_tab_select_text_color", "saas_tab_indicator_color"}, requireAll = false)
    public static void SegmentTabLayoutBinding(SegmentTabLayout layout, @ColorInt int tabSelectTextColor, @ColorInt int tab_indicator_color) {
        if (layout != null) {
            if (tabSelectTextColor != 0) {
                layout.setTextSelectColor(tabSelectTextColor);
            }
            if (tab_indicator_color != 0) {
                layout.setIndicatorColor(tab_indicator_color);
            }
        }
    }

    @BindingAdapter(value = {"saas_tab_select_text_color", "saas_tab_indicator_color"}, requireAll = false)
    public static void SlidingTabLayoutBinding(SlidingTabLayout layout, @ColorInt int tabSelectTextColor, @ColorInt int tab_indicator_color) {
        if (layout != null) {
            if (tabSelectTextColor != 0) {
                layout.setTextSelectColor(tabSelectTextColor);
            }
            if (tab_indicator_color != 0) {
                layout.setIndicatorColor(tab_indicator_color);
            }
        }
    }

    @BindingAdapter(value = {"saas_tab_select_text_color", "saas_tab_indicator_color"}, requireAll = false)
    public static void CommonTabLayoutBinding(CommonTabLayout layout, @ColorInt int tabSelectTextColor, @ColorInt int tab_indicator_color) {
        if (layout != null) {
            if (tabSelectTextColor != 0) {
                layout.setTextSelectColor(tabSelectTextColor);
            }
            if (tab_indicator_color != 0) {
                layout.setIndicatorColor(tab_indicator_color);
            }
        }
    }
}
